﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Psl.Chat;

namespace Stl.Chat.Remoting.Plugin
{
    class ThreadSafeProxy : NeutralProxy
    {
        // Constructeur
        public ThreadSafeProxy(IChat remote)
            : base(remote)
        {
        }

        #region IChat Members

        public override void Add(string userID, string message)
        {
            lock (remote)
            {
                base.Add(userID, message);
            }
        }

        //public event ChatChangedEventHandler ChatChanged;

        public override int Chrono
        {
            get { return remote.Chrono; }
        }

        public override void Clear()
        {
            lock (remote)
            {
                remote.Clear();
            }
        }

        public override int Count
        {
            get { return remote.Count; }
        }

        public override ChatItem[] GetLasts(int from)
        {
            return remote.GetLasts(from);
        }

        public override string GetNewUserID()
        {
            lock (remote)
            {
                return remote.GetNewUserID();
            }
        }

        public override ChatItem[] History
        {
            get { return remote.History; }
        }

        public override ChatItem this[int index]
        {
            get
            {
                lock (remote)
                {
                    return remote[index];
                }
            }
        }

        #endregion

    }
}
